package com.liting.uitest.model;

import com.liting.uitest.entity.FileInfo;
import com.liting.uitest.utils.FileUtil;
import lombok.Data;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.imgcodecs.Imgcodecs;

/**
 * 图片信息
 */
@Data
public class ImageInfo {
    static {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    }

    private FileInfo fileInfo;
    private String absultPath;
    private Mat colorImage;
    private int width;
    private int height;


    public ImageInfo(FileInfo fileInfo) {
        this.fileInfo = fileInfo;
        this.absultPath = FileUtil.getFilePath(fileInfo.getFilePath());
        // 加载图像
        Mat colorImage = Imgcodecs.imread(this.absultPath);
        this.colorImage = colorImage;
        // 获取图像的宽度和高度
        this.width = colorImage.width();
        this.height = colorImage.height();
    }
}
